<?php

include 'config.php';

# objlib library code
include "{$objLibDir}/pdoExt.php";
include "{$objLibDir}/Util.php";
include "{$objLibDir}/Object.php";
include "{$objLibDir}/JoinerRelation.php";
include "{$objLibDir}/SortedJoinerRelation.php";
include "{$objLibDir}/KeyRelation.php";
include "{$objLibDir}/SortedKeyRelation.php";
include "{$objLibDir}/Query.php";
include "{$objLibDir}/Node.php";

# englopya library code
include_once "{$componentDir}/Component.php";
include_once "{$componentDir}/ComponentContainer.php";
foreach (glob ("{$componentDir}/*.php") as $includeFile) {
	include_once ($includeFile);
}

# englopya Relations
foreach (glob ("{$relationsDir}/*.php") as $includeFile) {
	include_once ($includeFile);
}

include "{$rootDir}/dbConn.php";

if (isset($_SERVER['PATH_INFO'])) {
	$urlArray = explode ('/', $_SERVER['PATH_INFO']);
	array_shift ($urlArray);

	$url = new ComponentURL (false, $urlArray[0]);
	if ($url->id()) {
		$component = $url->getComponent();
		array_shift ($urlArray);
	}
	else {
		$component = Page::getDefaultPage ();
	}
	
	echo $component->render ($urlArray);	
}
else {
	echo Page::getDefaultPage()->render();
}

?>